package com.oot2d.ui;

import com.oot2d.entity.NPC;
import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;

public class Target {
    private Image tar;
    private NPC npc;
    private float x, y;

    public Target(NPC n)
    {
        System.out.println("New target created");
        npc = n;

        try {
            tar = new Image("res/ui/target.png", false, Image.FILTER_NEAREST);
        } catch (SlickException e) {
            System.err.println(e.getMessage());
        }
    }

    public void update(int d)
    {
        x = npc.getCenterX() - 12.0f;
        y = npc.getCenterY() - 12.0f;

        tar.rotate(0.1f * d);
    }

    public void render(Graphics g)
    {
        if (npc.isAttackable())
            g.drawImage(tar, x, y, new Color(248, 211, 5));
        else
            g.drawImage(tar, x, y, new Color(157, 153, 255));
    }
}
